This page last changed on Nov 15, 2007 by tschaub.

About GeoJSON

JSON is a lightweight data-interchange format based on a subset of the JavaScript programming language. This makes it an ideal interchange format for browser based applications since it can be parsed directly in to javascript very easily. GeoJSON is an emerging standard to add geographic types to JSON. As of writing it is at Draft 2.

Installing GeoJSON on GeoServer

Right now GeoJSON output is shipped as a plug-in to GeoServer, which means you have to download it independently. It is available on sourceforge. The advantage of making it an independent download is that you can install it on older versions of GeoServer. It is definitely compatible with all the 1.5.x series, and may work on 1.4.x as well. After you download it, unzip and put the contents of the folder in to <GEOSERVER_HOME>/webapps/geoserver/WEB-INF/lib. Then restart GeoServer and it should appear

Using GeoJSON output

To see if you installed it correctly, do a GetCapabilities WFS request - http://localhost:8080/geoserver/wfs?request=GetCapabilities This return 'JSON' as one of the output formats for GetFeature. If it doesn't then you probably did something wrong. If it did you can try out a json request. It's the same as all WFS requests, you just add outputformat=json to the request string (or as an xml property). For example:

This should yield a text string of JSON, which you can then post in to the OpenLayers GeoJSON Viewer. This should look like:

If you're doing a fully browser based front end to GeoServer we definitely recommend you make use of the JSON output, as it's lighter weight and should be more efficient than GML.


geojson-ol.png (image/png)
Document generated by Confluence on Jan 16, 2008 23:27